package model;

/**
 * This class uses the Player object, and will be used to show only pertinent information on the GUI
 */

import java.io.Serializable;
import model.Player.RoundStatus;

public class PlayerInformation implements Serializable{
	private String username;
	private Hand hand;
	private int status;
	private int chips;
	private int lastBet;
	
	/**
	 * Constructor, take the given parameters to update the PlayerInformation object
	 */
	public PlayerInformation(String username, Hand hand, RoundStatus status, int chips, int lastBet){
		
		this.username = username;
		this.hand = hand;
		this.chips = chips;
		this.lastBet = lastBet;
		
		/* Set the round status of the player to its integer representation
		 * 0 represents WAITING_FOR_TURN, 1 IN_TURN, -1 INACTIVE, 4 WON
		 */
		switch(status){
		case WAITING_FOR_TURN:
			this.status = 0;
			break;
		case IN_TURN:
			this.status = 1;
			break;
		case INACTIVE:
			this.status = -1;
			break;
		case WON:
			this.status = 4;
			break;
		}
	}
	
	//Getters and setters:
	
	public Hand getHand() {
		return hand;
	}
	
	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public int getChips() {
		return chips;
	}

	public void setChips(int chips) {
		this.chips = chips;
	}

	public int getLastBet() {
		return lastBet;
	}

	public void setLastBet(int lastBet) {
		this.lastBet = lastBet;
	}

	/**
	 * @param index position of the desired card in the player's hand
	 * @return the card at the desired position in the hand
	 */
	public Card getCard(int index){
		return hand.getHand().get(index);
	}
	
	/**
	 * @return true if the players status is IN_TURN (integer value 1), false otherwise
	 */
	public boolean inTurn(){
		return status == 1;
	}
}
